package com.hhit.zhgd.service

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.hhit.zhgd.domain.entity.OperateLog
import org.junit.jupiter.api.Test

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
internal class OperateLogServiceTest {
    @Autowired
    private val operateLogService: OperateLogService? = null

    @Test
    fun save() {
        operateLogService?.save(
            adminId = 1L,
            url = "http://test.com",
            method = "GET",
            params = "{}",
            ip = "test"
        )
    }

    @Test
    fun getList() {
        val page = Page<OperateLog>(1, 10)
        val params = HashMap<String,Any?>().also {
            it["start"] = "2023-09-22"
            it["end"] = "2023-10-17"
            it["username"] = "admin"
        }
        val list = operateLogService?.getList(page, params)
        list.also {
            it?.records?.forEach { item ->
                println("${item["id"]},${item["username"]},${item["url"]},${item["method"]},${item["params"]},${item["ip"]}")
            }
        }
    }
}